import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [{
        // 一进入项目，就跳转到跟目录
        path: '/',
        // 将跟目录设置为登录页面
        redirect: '/login'
    },
    {
        path: '/home',
        alias: '',
        name: 'Home',
        component: () =>
            import ('../views/Home.vue'),

        redirect: '/welcome',
        meta: {
            auth: true
        },
        children: [{
                path: 'welcome',
                name: 'Welcome',
                component: () =>
                    import ('../components/Welcome.vue')

            },
            {
                path: 'users',
                name: 'Users',
                component: () =>
                    import ('../components/Users.vue')
            },
            {
                path: 'roles',
                name: 'roles',
                component: () =>
                    import ('../components/Roles.vue')
            },
            {
                path: 'rights',
                name: 'Rights',
                component: () =>
                    import ('../components/Rights.vue')
            },
            {
                path: 'goods',
                name: 'Goods',
                component: () =>
                    import ('../components/Goods.vue'),
                // children: []
            },
            {
                path: 'params',
                name: 'Params',
                component: () =>
                    import ('../components/Params.vue')
            },
            {
                path: 'categories',
                name: 'Categories',
                component: () =>
                    import ('../components/Categories.vue')
            },
            {
                path: 'orders',
                name: 'Orders',
                component: () =>
                    import ('../components/Orders.vue')
            },
            {
                path: 'reports',
                name: 'Reports',
                component: () =>
                    import ('../components/Reports.vue')
            },
            {
                path: 'addGood',
                name: 'AddGood',
                component: () =>
                    import ('../components/AddGood.vue')
            }

        ]
    },
    {
        path: '/login',
        name: 'Login',
        component: () =>
            import ('../views/Login.vue')
    },
]

const router = new VueRouter({
    mode: 'hash',
    routes
})

export default router